<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>symbol</title>
</head>
<body>

</body>
</html>
<script>
    let h = {name: "wuhah"}
    const obj = Symbol(h);
    console.log(obj)
    let a = Symbol("1");
    let b = Symbol("1");
    console.log(a === b);
    console.log(a.description);
    let mySymbol = Symbol();
    let a1 = {[mySymbol]: "hello"};
    a1[mySymbol] = "你好";
    console.log(a1);
    const log = {};

    log.levels = {
        DEBUG: Symbol('debug'),
        INFO: Symbol('info'),
        WARN: Symbol('warn')
    };
    console.log(log.levels.DEBUG, 'debug message');
    console.log(log.levels.INFO, 'info message');
    let c1 = Symbol()

    function ab(a, b) {
        let c = 0;
        switch (a) {
            case c1:
                c = 100;
                break
        }
        return c
    }
    // ab(1,2);
    console.log(ab(c1, 2));
//    ================================================
    let s1=Symbol("foo");
    let s2=Symbol("foo");
    console.log(s1,s2);
    console.log(s1.toString())
    console.log(s2.description);
    console.log(!Boolean(s2));
    // console.log(Number(s2));
//
// symbol不可以与其他的类型在一块运算
//     console.log("hh"+s2);
//设计之初就是为了作为属性名
    let aa={[Symbol()]:"哇哦"};
    let s3=Symbol();
    aa[s3]="你好";
    Object.defineProperty(aa,Symbol(),{value:"zaijian"});
    aa.s3="漂亮";
    console.log(aa);
</script>